#ifndef  M_TEST_MATERIAL
#define M_TEST_MATERIAL
#include"material.h"
#include"../BxDF/Disney.h"
#include"../BxDF/Specular.h"
#include"../BxDF/Lambertian.h"
class TestMaterial :public Material
{
private:
	Float kd, kt,eta;//coefficients for diffuse term and highlight term

public:
	TestMaterial(Float kd, Float kt,Float eta=1.5) :
		kd(kd), kt(kt),eta(eta) {}

	shared_ptr<BSDF> createBSDF(Spectrum &color, P3 &norm, TransportMode mode)
	{
		shared_ptr<BSDF> bsdf(new BSDF(norm,eta));

		Spectrum diffColor = kd * color;

		Float Cdlum = color.y(); // luminance approx.
								 // normalize lum. to isolate hue+sat
		Spectrum Ctint = Cdlum > 0 ? (color / Cdlum) : Spectrum(1.f);
		Float ax = 0.04f;
		Float ay = 0.04f;
		//using TrowbridgeReitz distribution.
		Distrib *distribution = new Distrib(ax, ay, true);
		Spectrum Cspec0 = mix(SchlickR0FromEta(eta)*mix(Spectrum(1), Ctint, 0), color, 0);
		bsdf->addBxDF(new DisneyMicroFacetReflection(Spectrum(1), Cspec0, 0, eta, distribution));

		//bsdf->addBxDF(new LambertianReflection(diffColor));

		Spectrum transColor = kt * Spectrum(1);
		bsdf->addBxDF(new SpecularTransmission(eta,transColor));
		return bsdf;
	}

};
#endif // ! M_TEST_MATERIAL